package com.gzc.just.play.last.war.sceneserver.damage;

/**
 * 伤害结果DTO - 表示一次伤害计算的结果
 * 
 * @author AI Assistant
 * @version 1.0.0
 * @since 2025-11-22
 */
public class DamageResult {
    private long attackerId;            // 攻击者ID
    private long defenderId;            // 防守者ID
    private int baseDamage;             // 基础伤害
    private int damageAfterBonus;       // 加成后伤害
    private int damageAfterDefense;     // 防御后伤害
    private int finalDamage;            // 最终伤害
    
    private DamageType damageType;      // 伤害类型
    private boolean isCritical;         // 是否暴击
    private float criticalMultiplier;   // 暴击倍数
    
    private boolean isLethal;           // 是否致命一击
    private boolean isDodged;           // 是否躲避
    private boolean isResisted;         // 是否抵抗
    
    private long timestamp;             // 时间戳
    private String damageReason;        // 伤害原因（如技能名称）
    
    // Getter和Setter方法
    public long getAttackerId() {
        return attackerId;
    }
    
    public void setAttackerId(long attackerId) {
        this.attackerId = attackerId;
    }
    
    public long getDefenderId() {
        return defenderId;
    }
    
    public void setDefenderId(long defenderId) {
        this.defenderId = defenderId;
    }
    
    public int getBaseDamage() {
        return baseDamage;
    }
    
    public void setBaseDamage(int baseDamage) {
        this.baseDamage = baseDamage;
    }
    
    public int getDamageAfterBonus() {
        return damageAfterBonus;
    }
    
    public void setDamageAfterBonus(int damageAfterBonus) {
        this.damageAfterBonus = damageAfterBonus;
    }
    
    public int getDamageAfterDefense() {
        return damageAfterDefense;
    }
    
    public void setDamageAfterDefense(int damageAfterDefense) {
        this.damageAfterDefense = damageAfterDefense;
    }
    
    public int getFinalDamage() {
        return finalDamage;
    }
    
    public void setFinalDamage(int finalDamage) {
        this.finalDamage = finalDamage;
    }
    
    public DamageType getDamageType() {
        return damageType;
    }
    
    public void setDamageType(DamageType damageType) {
        this.damageType = damageType;
    }
    
    public boolean isCritical() {
        return isCritical;
    }
    
    public void setCritical(boolean critical) {
        isCritical = critical;
    }
    
    public float getCriticalMultiplier() {
        return criticalMultiplier;
    }
    
    public void setCriticalMultiplier(float criticalMultiplier) {
        this.criticalMultiplier = criticalMultiplier;
    }
    
    public boolean isLethal() {
        return isLethal;
    }
    
    public void setLethal(boolean lethal) {
        isLethal = lethal;
    }
    
    public boolean isDodged() {
        return isDodged;
    }
    
    public void setDodged(boolean dodged) {
        isDodged = dodged;
    }
    
    public boolean isResisted() {
        return isResisted;
    }
    
    public void setResisted(boolean resisted) {
        isResisted = resisted;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    public String getDamageReason() {
        return damageReason;
    }
    
    public void setDamageReason(String damageReason) {
        this.damageReason = damageReason;
    }

    /**
     * 构造函数 - 快速创建基础伤害结果
     */
    public DamageResult(long attackerId, long defenderId, int finalDamage, DamageType damageType) {
        this.attackerId = attackerId;
        this.defenderId = defenderId;
        this.finalDamage = finalDamage;
        this.damageType = damageType;
        this.timestamp = System.currentTimeMillis();
        this.baseDamage = finalDamage;
        this.damageAfterBonus = finalDamage;
        this.damageAfterDefense = finalDamage;
        this.isCritical = false;
        this.criticalMultiplier = 1.0f;
        this.isLethal = false;
        this.isDodged = false;
        this.isResisted = false;
    }
    
    /**
     * 全参数构造函数 - 用于DamageCalculator
     */
    public DamageResult(long attackerId, long defenderId, 
                     int baseDamage, int damageAfterBonus, int damageAfterDefense, 
                     int finalDamage, DamageType damageType, 
                     boolean isCritical, float criticalMultiplier, 
                     boolean isLethal, boolean isDodged, boolean isResisted, 
                     long timestamp, String damageReason) {
        this.attackerId = attackerId;
        this.defenderId = defenderId;
        this.baseDamage = baseDamage;
        this.damageAfterBonus = damageAfterBonus;
        this.damageAfterDefense = damageAfterDefense;
        this.finalDamage = finalDamage;
        this.damageType = damageType;
        this.isCritical = isCritical;
        this.criticalMultiplier = criticalMultiplier;
        this.isLethal = isLethal;
        this.isDodged = isDodged;
        this.isResisted = isResisted;
        this.timestamp = timestamp;
        this.damageReason = damageReason;
    }

    /**
     * 获取伤害描述
     */
    public String getDescription() {
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("%s 对 %s 造成 %d 点%s伤害",
                attackerId, defenderId, finalDamage, damageType.getName()));

        if (isCritical) {
            sb.append(String.format("[暴击x%.1f]", criticalMultiplier));
        }
        if (isDodged) {
            sb.append("[已躲避]");
        }
        if (isResisted) {
            sb.append("[已抵抗]");
        }
        if (isLethal) {
            sb.append("[致命一击]");
        }
        if (damageReason != null && !damageReason.isEmpty()) {
            sb.append(String.format(" - %s", damageReason));
        }

        return sb.toString();
    }

    @Override
    public String toString() {
        return getDescription();
    }
}
